package com.xzz.feignFallback;

import com.xzz.feign.MediaFeignClient;
import com.xzz.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MediaFeignClientFallbackFactory implements FallbackFactory<MediaFeignClient> {
    @Override
    public MediaFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new MediaFeignClient() {
            @Override
            public JSONResult queryMediaByCourseId(Long courseId) {
                return JSONResult.error("媒体不可用");
            }

            @Override
            public JSONResult get(Long id) {
                return JSONResult.error("媒体不可用");
            }
        };
    }
}